<template>
  <van-dialog
    v-model="vshow"
    show-cancel-button
    :before-close="beforeClose"
    cancel-button-text="返回"
    :confirm-button-text="confirmButtonText"
    class="mydialog"
  >
    <i class="weui-icon-warn weui-icon_msg" v-if="confirmType === 'warn'"></i>
    <i class="weui-icon-info weui-icon_msg" v-if="confirmType === 'info'"></i>
    <div class="weui-dialog__hd"><strong class="weui-dialog__title">{{title}}</strong></div>
    <div class="weui-dialog__bd">
      <p>{{message}}</p>
      <p v-if="descri !== ''">{{descri}}</p>
    </div>
  </van-dialog>
</template>

<script>
export default {
  name: 'MyConfirm',
  props: ['confirmButtonText', 'confirmType', 'title', 'message', 'descri'],
  data () {
    return {
      vshow: false
    }
  },
  methods: {
    show () {
      this.vshow = true
    },
    beforeClose (action, done) {
      if (action === 'confirm') {
        this.$emit('myes')
        done()
      } else {
        this.$emit('mno')
        done()
      }
    }
  }
}
</script>

<style lang="stylus" scoped>
.mydialog >>> .van-dialog__content
  text-align center
  padding-top .6rem
.mydialog >>> .van-dialog__footer
  border-top 1px solid #eee
.mydialog >>> .van-dialog__footer .van-dialog__confirm
  border-left 1px solid #eee
  font-size 17px
  color #d92d21
</style>
